import React, { Component } from 'react';
import {Text, View} from '@tarojs/components'
import {http} from '../../utils/http'
import {GRADE_DETAILS, TARO_ENV} from "../../constants/api";
import {getContent} from "../../utils/handlerPublicCode";

type PageState = {
  applicationVipAgreement: any
}

export default class Service extends Component {
  state: PageState = {
    applicationVipAgreement: []
  };

  async UNSAFE_componentWillMount() {
    const data = await http.carGet(GRADE_DETAILS, {})
    this.setState({ applicationVipAgreement: data.application_vip_agreement })
  }

  render() {
    const {applicationVipAgreement} = this.state
    return (
      <View style='padding: 0 10px;'>
        {TARO_ENV === 'weapp' && <View>
          <parser selectable html={applicationVipAgreement || ''} />
        </View>}
        {TARO_ENV === 'tt' && <View>
          <rich-text preview selectable nodes={getContent(applicationVipAgreement)} />
        </View>}
        {TARO_ENV === 'h5' && <Text style='display: inline-block;' selectable>
          <View dangerouslySetInnerHTML={{__html: applicationVipAgreement}} />
        </Text>}
      </View>
    )
  }
}
